<template>
  <div class="user">
    <van-cell-group>
      <van-cell class="user-info">
        <van-image
          round
          width="50"
          height="50"
          :src="userInfo.portrait || 'https://s20.lgstatic.com/growth/activity/20210720/1626784734098.jpeg?x-oss-process=style/80'"
        ></van-image>
        <div class="user-info-content">
          <h3>{{ userInfo.userName }}</h3>
          <span>
            <van-icon name="edit">编辑个人资料</van-icon>
          </span>
        </div>
      </van-cell>
      <van-grid class="account-info">
        <van-grid-item>
          <span class="grid-item-value">14.05</span>
          <span>学习时长</span>
        </van-grid-item>
        <van-grid-item>
          <span class="grid-item-value">200</span>
          <span>钱包/勾豆</span>
        </van-grid-item>
        <van-grid-item>
          <span class="grid-item-value">1</span>
          <span>优惠券</span>
        </van-grid-item>
        <van-grid-item>
          <span class="grid-item-value">212</span>
          <span>学分</span>
        </van-grid-item>
      </van-grid>
      <van-cell icon="user-o" title="分销中心" is-link value="收益200元"></van-cell>
      <van-cell icon="setting-o" title="个性化设置" is-link></van-cell>
      <van-cell icon="down" title="我的下载" is-link></van-cell>
      <van-cell icon="question-o" title="帮助和反馈" is-link></van-cell>
      <van-cell icon="info-o" title="关于拉勾教育" is-link value="v2.0.0"></van-cell>
    </van-cell-group>
    <layout-footer></layout-footer>
  </div>
</template>

<script>
import LayoutFooter from '@/components/LayoutFooter'
import { getInfo } from '@/services/user'
export default {
  name: 'User',
  components: {
    LayoutFooter
  },
  data () {
    return {
      userInfo: {}
    }
  },
  created () {
    this.loadUserInfo()
  },
  methods: {
    async loadUserInfo () {
      const { data } = await getInfo()
      this.userInfo = data.content
    }
  }
}
</script>

<style lang="scss" scoped>
.user-info {
  padding: 30px 20px;
  background-color: rgb(248, 150, 3);
}

.van-cell__value {
  display: flex;
}

.user-info-content {
  padding-left: 15px;
}

.user-info-content h3 {
  margin: 5px;
  font-size: 18px;
}

.account-info {
  margin-top: -1px;
  font-size: 14px;
}

.account-info .van-cell__value {
  border-radius: 10px;
}

.account-info .grid-item-value {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 5px;
}
</style>
